<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>确认入库单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <link rel="stylesheet" href="../../lib/layui/css/layui.css"  media="all">
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script src="../../js/MyCommon.js"></script>
</head>
<body>




<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form ">
                        <div class="x-nav">
                          <span class="layui-breadcrumb">
                            <a href="">首页</a>
                            <a><cite>确认入库单/Confirm receipt</cite></a>
                          </span>
                               <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
                               onclick="location.reload()" title="刷新">
                                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
                        </div>
                        <br>
                        <div class="layui-inline">
                            <div class="layui-input-inline ">
                                <input type="text" name="documentNo" id="documentNo" placeholder="请输入单据号"
                                       class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline" style="display: none">
                            <label class="layui-form-label">开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="startTime" id="startTime" readonly="readonly" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline" style="display: none">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="endTime" id="endTime" readonly="readonly" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <div class="layui-input-inline ">
                                <button type="button" class="layui-btn layui-btn-warm" id="sreach"><span class="layui-icon">&#xe615;</span>查询</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-hide" id="warTable" lay-filter="Monitor"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-sm" lay-event="excel">导出入库单</button>
    </div>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看详情</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
    $(function () {
        loadpage();
    })

    function loadpage() {
        var documentNo = $("#documentNo").val();
        //console.log(params);
        renderdata(documentNo);
    }

    function renderdata(documentNo) {
        requestAjax("/JT90/confirm/get", "post", "json", "documentNo="+documentNo, function (res) {
            var data = res.data;
            render(data);
        })
    }


    function render(data) {
        layui.use(['table', 'layer', 'form', 'laypage','laydate'], function () {
            var table = layui.table;
            var    layer = layui.layer;
            var    form = layui.form;
            var   laypage = layui.laypage;
            var  laydate=layui.laydate;

            table.render({
                elem: '#warTable'
                ,toolbar:"#toolbarDemo"//开启头部工具栏，并为其绑定左侧模板
                ,defaultToolbar:[]
                ,data: data
                ,title: '确认入库单表'
                ,cols: [[
                     {type: 'checkbox', fixed: 'left'}
                    ,{type: 'numbers', title: '序号'}
                    ,{field: 'documentNo', title: '单据号', align: "center"}
                    , {field: 'wareEntry', title: '录入人', align: "center"}
                    , {field: 'wareTime', title: '录入时间', align: "center"}
                    , {field: 'wareRemarks', title: '备注', align: "center"}
                    , {fixed: 'right', title: '操作', toolbar: '#barDemo', align: "center"}
                ]]

                ,page: {
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                    , groups: 5 //只显示 1 个连续页码
                    , first: false//不显示首页
                    , last: false //不显示尾页
                    , limit: 5
                    , limits: [5, 10, 15, 20]
                    , theme: '#44cc33'
                }
            });

            //导出出库单
            table.on('toolbar(Monitor)', function(obj) {
                if (obj.event === "excel") {
                    layer.msg("正在导出入库单据表");
                    location.href="/JT90/WarehouseExcel/write"
                }
            })


            //监听行工具事件
            table.on('tool(Monitor)', function (obj) {
                var data = obj.data;
                var documentNo=data.documentNo;
                // console.log(documentNo)
                if (obj.event === 'detail') {
                    // 查看入库单详情
                    layer.open({
                        type:2,
                        title:['查看入库单详情','color:#fff;background-color:#01AAED;'],
                        skin:"layui-layer-lan",
                        content:'5.2detail.html?documentNo='+documentNo,
                        area:['600px','400px']
                        })
                } else if (obj.event === 'edit') {
                    //编辑入库单
                    layer.open({
                        type:2,
                        title:['编辑入库单','color:#fff;background-color:#01AAED;'],
                        skin:"layui-layer-lan",
                        content:'5.2edit.html?documentNo='+documentNo,
                        area:['600px','400px']
                    })

                } else if (obj.event === 'del') {
                    layer.confirm('确定删除吗?',{icon:2},function (index) {
                         requestAjax("/JT90/confirm/delete", "get", "json","documentNo="+documentNo, function (res) {
                                if(res.success){
                                    layer.msg('删除成功！',{icon: 6});
                                }else{
                                    layer.msg('删除失败！',{icon: 5});
                                }
                        })
                        obj.del();
                        layer.close(index);
                    });
                }
            });
        });
    }


    //监听提交
    $("#sreach").click(function () {
        loadpage();
    });


</script>
</html>
